<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
		<title>基本配置</title>
		<link href="../../component/pear/css/pear.css" rel="stylesheet">
	</head>
	<body class="pear-container">
		<form class="layui-form" lay-filter="form_config">
			<div class="layui-row layui-col-space10">
				<div class="layui-col-md6">
					<div class="layui-card" lay-filter="component-form-element">
						<div class="layui-card-header">WAF设置</div>
						<div class="layui-card-body layui-row layui-col-space10">
							<div class="layui-col-md6">
								<label class="layui-form-label">WAF开关</label>
								<div class="layui-input-block">
									<input type="checkbox" name="waf" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
								</div>
							</div>
							<div class="layui-col-md6">
								<label class="layui-form-label">工作模式</label>
								<div class="layui-input-block">
									<select name="mode" lay-filter="config_select">
										<option value="protection">防御</option>
										<option value="monitor">监控</option>
									</select>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-card" lay-filter="component-form-element">
						<div class="layui-card-header">规则设置</div>
						<div class="layui-card-body layui-row layui-col-space10">
							<div class="layui-col-md6">
								<label class="layui-form-label">自动排序</label>
								<div class="layui-input-block">
									<input type="checkbox" name="rules_sort" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
								</div>
							</div>
							<div class="layui-col-md6">
								<label class="layui-form-label">排序间隔</label>
								<div class="layui-input-group">
									<input type="text" name="rules_sort_period" lay-verify="required|number" lay-filter="config_input" autocomplete="off" class="layui-input" />
									<div class="layui-input-suffix">秒</div>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-card" lay-filter="component-form-element">
						<div class="layui-card-header">攻击日志设置</div>
						<div class="layui-card-body">
							<div class="layui-row layui-col-space10">
								<div class="layui-col-md6">
									<label class="layui-form-label">记录日志</label>
									<div class="layui-input-block">
										<input type="checkbox" name="attackLog" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
									</div>
								</div>
								<div class="layui-col-md6">
									<label class="layui-form-label" style="width: auto;">Json格式日志</label>
									<div class="layui-input-block">
										<input type="checkbox" name="attackLog_json_format" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
									</div>
								</div>
							</div>
							<div class="layui-row layui-col-space10">
								<div class="layui-col-md12">
									<label class="layui-form-label" style="width: auto;">日志保存路径</label>
									<div class="layui-input-block" style="margin-left: 115px;">
										<input type="text" name="logPath" lay-verify="required|pathRule" lay-filter="config_input" autocomplete="off" class="layui-input" />
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-card" lay-filter="component-form-element">
						<div class="layui-card-header">IP地理位置识别设置</div>
						<div class="layui-card-body">
							<div class="layui-row layui-col-space10">
								<div class="layui-col-md12">
									<label class="layui-form-label">IP位置识别</label>
									<div class="layui-input-block">
										<input type="checkbox" name="geoip" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
									</div>
								</div>
							</div>
							<div class="layui-row layui-col-space10" style="margin-bottom: 5px;">
								<div class="layui-col-md12">
									<label class="layui-form-label" style="width: auto;">GeoIP数据文件路径</label>
									<div class="layui-input-block" style="margin-left: 155px;">
										<input type="text" name="geoip_db_file" lay-verify="required|pathRule" lay-filter="config_input" autocomplete="off" class="layui-input" />
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="layui-col-md6">
					<div class="layui-card" lay-filter="component-form-element">
						<div class="layui-card-header">其它设置</div>
						<div class="layui-card-body">
							<div class="layui-row layui-col-space10">
								<div class="layui-col-md6">
									<label class="layui-form-label">请求体检查</label>
									<div class="layui-input-block">
										<input type="checkbox" name="requestBodyCheck" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
									</div>
								</div>
								<div class="layui-col-md6">
									<label class="layui-form-label">Cookie检查</label>
									<div class="layui-input-block">
										<input type="checkbox" name="cookie" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
									</div>
								</div>
							</div>
							<div class="layui-row layui-col-space10">
								<div class="layui-col-md6">
									<label class="layui-form-label">Sql注入检查</label>
									<div class="layui-input-block">
										<input type="checkbox" name="sqli" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
									</div>
								</div>
								<div class="layui-col-md6">
									<label class="layui-form-label">XSS检查</label>
									<div class="layui-input-block">
										<input type="checkbox" name="xss" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
									</div>
								</div>
							</div>
						</div>
					</div>

					<div class="layui-card" lay-filter="component-form-element">
						<div class="layui-card-header">文件上传</div>
						<div class="layui-card-body">
							<div class="layui-row layui-col-space10">
								<div class="layui-col-md12">
									<label class="layui-form-label" style="width: auto;">上传文件内容检查</label>
									<div class="layui-input-block">
										<input type="checkbox" name="fileContentCheck" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
									</div>
								</div>
							</div>
							<div class="layui-row layui-col-space10">
								<div class="layui-col-md12">
									<label class="layui-form-label" style="width: auto;">上传文件类型黑名单</label>
									<div class="layui-btn-container tag" lay-filter="fileExtBlackList" lay-allowclose="true" lay-newTag="true" id="fileExtBlackList"></div>
								</div>
							</div>
						</div>
					</div> 

					<div class="layui-card" lay-filter="component-form-element">
						<div class="layui-card-header">密钥设置</div>
						<div class="layui-card-body layui-row layui-col-space10">
							<div class="layui-col-md6">
								<input type="text" name="secret" lay-verify="required|secretRule" lay-filter="config_input" autocomplete="off" class="layui-input" />
							</div>
							<div class="layui-col-md6" style="padding-top: 12px;">用于请求签名等，建议长度长一点</div>
						</div>
					</div>
					<div class="layui-card" lay-filter="component-form-element">
						<div class="layui-card-header">HTTP方法白名单</div>
						<div class="layui-card-body layui-row layui-col-space10">
							<div class="layui-col-md12">
								<input type="checkbox" name="methodWhiteList" lay-filter="config_checkbox" value="GET" title="GET" />
								<input type="checkbox" name="methodWhiteList" lay-filter="config_checkbox" value="POST" title="POST" />
								<input type="checkbox" name="methodWhiteList" lay-filter="config_checkbox" value="HEAD" title="HEAD" />
								<input type="checkbox" name="methodWhiteList" lay-filter="config_checkbox" value="PUT" title="PUT" />
								<input type="checkbox" name="methodWhiteList" lay-filter="config_checkbox" value="DELETE" title="DELETE" />
								<input type="checkbox" name="methodWhiteList" lay-filter="config_checkbox" value="OPTIONS" title="OPTIONS" />
								<input type="checkbox" name="methodWhiteList" lay-filter="config_checkbox" value="PATCH" title="PATCH" />
								<input type="checkbox" name="methodWhiteList" lay-filter="config_checkbox" value="TRACE" title="TRACE" />
								<input type="checkbox" name="methodWhiteList" lay-filter="config_checkbox" value="CONNECT" title="CONNECT" />
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-row layui-col-space10" style="margin-top: 16px;">
				<div class="layui-col-md4 layui-col-md-offset4">
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button type="submit" class="pear-btn pear-btn-primary" lay-submit lay-filter="config_save">保存</button>
							<button type="reset" class="pear-btn" style="margin-left: 16px;">重置</button>
						</div>
					</div>
				</div>
			</div>
		</form>
		<script src="../../component/layui/layui.js"></script>
		<script src="../../component/pear/pear.js"></script>
		<script src="../../js/config.js"></script>

		<script>
			layui.use(['tag','popup'], function() {
				var $ = layui.jquery;
				var	tag = layui.tag;
				var popup = layui.popup;

				tag.on('add(fileExtBlackList)', function(data) {
					var newText = $(data.othis).text().trim();
					var exists = false;
					$('#fileExtBlackList').find('button').each(function(i, el) {
						if (newText == $(el).text().replace('ဆ','').trim()) {
							exists = true;
							return;
						}
					});
					if (exists) {
						popup.failure('扩展名已存在');
						return false;
					}
				});
			});
		</script>
	</body>
</html>
